package com.persistence;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity(name = "PRIMARYMEMBER")
@Table(name = "primarymember")
public class Primarymember implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@TableGenerator(name = "PRIMARY_SEQ", table = "tbsequence", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "PRIMARY_IDX", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "PRIMARY_SEQ")
	@Column(name = "ID")
	private String id;

	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "CONTACTINFO", referencedColumnName = "ID", insertable = true, updatable = true)
	private Contactinfo contactinfoBean;

	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "ADDRESS", referencedColumnName = "ID", insertable = true, updatable = true)
	private Address addressBean;

	@Column(name = "LASTNAME")
	private String lastname;

	@Column(name = "FIRSTNAME")
	private String firstname;

	@Column(name = "GENDER")
	private short gender;

	@Column(name = "BIRTHDATE")
	@Temporal(value = TemporalType.TIMESTAMP)
	private Date birthdate;

	@OneToOne(optional = true, cascade = CascadeType.ALL, mappedBy = "primarymemberBean", targetEntity = Membership.class)
	private Membership memberships;

	public Primarymember() {
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getBirthdate() {
		return this.birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	public String getFirstname() {
		return this.firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public short getGender() {
		return this.gender;
	}

	public void setGender(short gender) {
		this.gender = gender;
	}

	public String getLastname() {
		return this.lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public Membership getMemberships() {
		return this.memberships;
	}

	public void setMemberships(Membership memberships) {
		this.memberships = memberships;
	}

	public Address getAddressBean() {
		return this.addressBean;
	}

	public void setAddressBean(Address addressBean) {
		this.addressBean = addressBean;
	}

	public Contactinfo getContactinfoBean() {
		return this.contactinfoBean;
	}

	public void setContactinfoBean(Contactinfo contactinfoBean) {
		this.contactinfoBean = contactinfoBean;
	}

}